package nc.ui.arap.actions;

import nc.vo.arap.global.DjVOTreaterAid;
import nc.vo.ep.dj.DJZBHeaderVO;
import nc.vo.ep.dj.DJZBItemVO;
import nc.vo.ep.dj.DJZBVO;
import nc.vo.jcom.lang.StringUtil;
import nc.vo.ml.NCLangRes4VoTransl;
import nc.vo.pub.BusinessException;

public class CheckBillItemValueAction extends DefaultAction {

	public void checkNullBefSave(DJZBVO djzbvo) throws BusinessException {
		DJZBHeaderVO headvo = ((DJZBHeaderVO) djzbvo.getParentVO());
		DJZBItemVO[] items = (DJZBItemVO[]) djzbvo.getChildrenVO();
		String wldx = null;
		String RES = "";

		// List<String> lst=new ArrayList<String>();
		StringBuffer sb = new StringBuffer();
		String line;
		boolean istr = true;
		for (int i = 0, size = items.length; i < size; i++) {
			if(DjVOTreaterAid.isBCLine(items[i])){
				continue;
			}
			if (items[i].getWldx() != null) {
				if (items[i].getWldx().intValue() == 2) {
					wldx = "deptid";
					RES = NCLangRes4VoTransl.getNCLangRes().getStrByID("200602", "UPT200602-v35-000024");
				} else if (items[i].getWldx().intValue() == 3) {
					wldx = "ywybm";
					RES = NCLangRes4VoTransl.getNCLangRes().getStrByID("200602", "UPT200602-v35-000026");
				} else {
					wldx = "hbbm";

					RES = NCLangRes4VoTransl.getNCLangRes().getStrByID("200602", "UPT200602-v35-000025");
				}
			}
			line = "";
			istr = true;
			if (StringUtil.isEmptyWithTrim(items[i].getBzbm())) {
				line += NCLangRes4VoTransl.getNCLangRes().getStrByID("2006030102", "UPP2006030102-000193") + NCLangRes4VoTransl.getNCLangRes().getStrByID("2006030102", "UPP2006030102-000516");
				istr = false;
			}
//			if (ArapCommonTool.isZero(items[i].getJfybje().add(items[i].getDfybje()))) {
//				line += NCLangRes4VoTransl.getNCLangRes().getStrByID("2006030102", "UPP2006030102-001056") + NCLangRes4VoTransl.getNCLangRes().getStrByID("2006030102", "UPP2006030102-000516");
//				istr = false;
//			}
//			if (ArapCommonTool.isZero(items[i].getJfbbje().add(items[i].getDfbbje()))) {
//				line += NCLangRes4VoTransl.getNCLangRes().getStrByID("200602", "UPT200602-v35-000023") + NCLangRes4VoTransl.getNCLangRes().getStrByID("2006030102", "UPP2006030102-000516");
//				istr = false;
//			}
			if (null != wldx && !"fj".equalsIgnoreCase(headvo.getDjdl()) && !"sj".equalsIgnoreCase(headvo.getDjdl()) && !"hj".equalsIgnoreCase(headvo.getDjdl())
					&& !"ss".equalsIgnoreCase(headvo.getDjdl())) {
				if (items[i].getAttributeValue(wldx) == null || items[i].getAttributeValue(wldx).toString().length() == 0) {
					line += RES;
					istr = false;
				}
			}
			if (!istr) {
				sb.append(NCLangRes4VoTransl.getNCLangRes().getStrByID("200602", "UPT200602-v35-000020", null, new String[] { String.valueOf(i + 1) })).append(line).append(
						NCLangRes4VoTransl.getNCLangRes().getStrByID("200602", "UPT200602-v35-000021"));

			}
		}
		if (sb.length() > 0) {
			nc.bs.logging.Log.getInstance(this.getClass()).warn(sb.toString());
			throw new BusinessException(sb.toString());
			//			getParent().showErrorMessage(sb.toString());

		}

	}

}
